/**
 * 工具函数
 */
'use strict';
var Food = Food || {};
Food.utils = {
    //日期格式化
    formatDate: function (date, fmt) {
        date = new Date(date);
        var o = {
            "M+": date.getMonth() + 1, //月份
            "d+": date.getDate(), //日
            "H+": date.getHours(), //小时
            "m+": date.getMinutes(), //分
            "s+": date.getSeconds(), //秒
            "q+": Math.floor((date.getMonth() + 3) / 3), //季度
            "S": date.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    },
    //获取页面参数
    getQueryString: function (name) {
        name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(location.href);
        return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }
};

/* App Module */
var indexApp = angular.module('indexApp', [
    'ngRoute',
    'controllers',
    'ui.grid',
    'ui.bootstrap',
    'ui.grid.resizeColumns',
    'ui.grid.pagination',
    'ui.grid.autoResize',
    'ui.grid.selection',
    'ui.bootstrap.datetimepicker',
    'nogyeadmin.childNav',
    'nogyeadmin.scheduleContent',
    'ngFileUpload'
]);

indexApp.config(['$routeProvider',
    function ($routeProvider) {

        $routeProvider.
            when('/member/addBackMember', {//新增后台管理员
                templateUrl: 'partials/member/addBackMember.html',
                controller: 'addBackMemberCtrl'
            }).
            when('/member/memberList', {//会员列表
                templateUrl: 'partials/member/memberList.html',
                controller: 'memberListCtrl'
            }).
            when('/member/userPostList', {//帖子管理
                templateUrl: 'partials/member/userPostList.html',
                controller: 'userPostListCtrl'
            });

        $routeProvider.
            when('/activity/bannerList', {//好物banner列表
                templateUrl: 'partials/activity/bannerList.html',
                controller: 'bannerListCtrl'
            }).
            when('/activity/activityDetail', {//好物banner列表
                templateUrl: 'partials/activity/activityDetail.html',
                controller: 'bannerDetailCtrl'
            }).
            when('/activity/goodItemList', {//好物商品列表
                templateUrl: 'partials/activity/goodItemList.html',
                controller: 'goodItemListCtrl'
            });

        $routeProvider.
            when('/item/itemList', {//商品列表
                templateUrl: 'partials/item/itemList.html',
                controller: 'itemListCtrl'
            }).
            when('/item/addItem', {//新增商品
                templateUrl: 'partials/item/addItem.html',
                controller: 'addItemCtrl'
            }).
            when('/item/updateItem', {//更新商品
                templateUrl: 'partials/item/updateItem.html',
                controller: 'updateItemCtrl'
            });

        $routeProvider.
            when('/image/imageList', {//商品列表
                templateUrl: 'partials/image/imageList.html',
                controller: 'imageListCtrl'
            });


        $routeProvider.
            when('/forest/forestList', {//类目列表
                templateUrl: 'partials/forest/forestList.html',
                controller: 'forestListCtrl'
            }).
            when('/forest/forestDetail', {//类目详情
                templateUrl: 'partials/forest/forestDetail.html',
                controller: 'forestDetailCtrl'
            }).
            when('/forest/addForest', {//增加类目
                templateUrl: 'partials/forest/addForest.html',
                controller: 'addForestCtrl'
            });

        $routeProvider.
            when('/property/propertyList', {//属性列表
                templateUrl: 'partials/property/propertyList.html',
                controller: 'propertyListCtrl'
            }).
            when('/property/addProperty', {//增加属性
                templateUrl: 'partials/property/addProperty.html',
                controller: 'addPropertyCtrl'
            }).
            when('/property/propertyDetail', {//增加属性
                templateUrl: 'partials/property/propertyDetail.html',
                controller: 'propertyDetailCtrl'
            }).
            when('/property/addPropertyValue', {//增加属值
                templateUrl: 'partials/property/addPropertyValue.html',
                controller: 'addPropertyValueCtrl'
            });


        $routeProvider.
            when('/vcoin/vCoinList', {//V币列表
                templateUrl: 'partials/vcoin/vCoinList.html',
                controller: 'coinListCtrl'
            }).when('/vcoin/tranDetailList', {//V币详情列表
                templateUrl: 'partials/vcoin/tranDetailList.html',
                controller: 'tranDetailListCtrl'
            }).when('/vcoin/businessAccountList', {//商户列表
                templateUrl: 'partials/vcoin/businessAccountList.html',
                controller: 'businessAccountListCtrl'
            }).when('/vcoin/businessTranDetailList', {//商户详情列表
                templateUrl: 'partials/vcoin/businessTranDetailList.html',
                controller: 'businessTranDetailListCtrl'
            });



        $routeProvider.
            when('/tran/rechargeOrderList', {//充值订单列表
                templateUrl: 'partials/order/rechargeOrderList.html',
                controller: 'rechargeOrderCtrl'
            }).when('/tran/disburseList', {//消费订单列表
                templateUrl: 'partials/order/disburseList.html',
                controller: 'disburseCtrl'
            }).when('/tran/sendGoods', {//更新商品
                templateUrl: 'partials/order/sendGoods.html',
                controller: 'sendGoodsCtrl'
            }).when('/tran/returnGoodsOrderList', {//退款订单列表
                templateUrl: 'partials/order/returnGoodsOrderList.html',
                controller: 'returnGoodsOrderCtrl'
            }).when('/tran/rebateInfoList', {//返佣列表
                templateUrl: 'partials/order/rebateInfoList.html',
                controller: 'rebateInfoCtrl'
            });

        $routeProvider.
            when('/system/operateFlowList', {//流水日志
                templateUrl: 'partials/system/operateFlowList.html',
                controller: 'operateFlowListCtrl'
            });

        $routeProvider.otherwise({
            templateUrl: 'partials/indexChild.html',
            controller: 'indexChildCtrl'
        });

    }]);


//indexApp.filter('reverse', function() {
//    return function(items) {
//        return items.slice().reverse();
//    };
//});
